package com.zbkj.admin.controller.platform.shop;

import com.github.pagehelper.PageInfo;
import com.zbkj.common.model.shop.EbPopularAreas;
import com.zbkj.common.request.EbPopularAreasRequest;
import com.zbkj.common.result.CommonResult;
import com.zbkj.service.service.EbPopularAreasService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@Slf4j
@RestController
@RequestMapping("/api/platform/edPopularAreas")
@Api(tags = "热门地区分类")
public class PlatformPopularAreasController {
    @Resource
    EbPopularAreasService ebPopularAreasService;

    /**
     * 增加热门地区
     *
     * @param ebPopularAreas
     * @return
     */
    @ApiOperation(value = "增加热门地区")
    @PostMapping(value = "/add")
    public CommonResult<EbPopularAreas> add(@RequestBody EbPopularAreas ebPopularAreas) {
        return CommonResult.success(ebPopularAreasService.add(ebPopularAreas));
    }


    /**
     * 修改热门地区
     *
     * @param ebPopularAreas
     * @return
     */
    @ApiOperation(value = "修改热门地区")
    @PostMapping(value = "/update")
    public CommonResult<EbPopularAreas> update(@RequestBody EbPopularAreas ebPopularAreas) {
        return CommonResult.success(ebPopularAreasService.update(ebPopularAreas));
    }

    /**
     * 查询详情
     *
     * @param id
     * @return
     */
    @ApiOperation(value = "查询详情")
    @GetMapping(value = "/get/{id}")
    public CommonResult<EbPopularAreas> get(@PathVariable("id") Integer id) {
        return CommonResult.success(ebPopularAreasService.getById(id));
    }

    /**
     * 查询列表
     *
     * @return
     */
    @ApiOperation(value = "查询列表")
    @PostMapping(value = "/getList")
    public CommonResult<List<EbPopularAreas>> getList(@RequestBody EbPopularAreasRequest ebPopularAreas) {
        return CommonResult.success(ebPopularAreasService.findByList(ebPopularAreas));
    }


    @ApiOperation(value = "分页查询列表")
    @PostMapping(value = "/getPage")
    public CommonResult<PageInfo<EbPopularAreas>> getPage(@RequestBody EbPopularAreasRequest ebPopularAreas) {
        return CommonResult.success(ebPopularAreasService.getPage(ebPopularAreas));
    }
}